package shuati;

import java.util.*;

/**
 * @author 23050
 * @version 1.0
 * @description: TODO
 * @date 2023/12/27 18:54
 */
public class Demo04 {

    private static List<Integer> ret = new ArrayList<>();
    private static Set<List<Integer>> set = new HashSet<>();
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int N = in.nextInt();
        int[] arr = new int[N];
        for(int i =0;i<N;i++){
            arr[i] = in.nextInt();
        }

        Set<Integer> tmp1 = new HashSet<>();
        for(int x:arr){
            tmp1.add(x);
        }
        int[] arr1 = new int[tmp1.size()];
        List<Integer> a = new ArrayList<>(tmp1);
        int[] arr2 = new int[a.size()];
        for(int i = 0;i<a.size() ;i++){
            arr2[i] = a.get(i);
        }

        Arrays.sort(arr2);


        dfs(arr2,0);
//        System.out.println(set);

        long sum = 0;
        List<List<Integer>> result = new ArrayList<>(set);
        for(List<Integer> tmp:result){
            sum += ((tmp.get(0)^tmp.get(1))%998244353+(tmp.get(2)^tmp.get(3))%998244353)%998244353;
        }
        System.out.println(sum);



    }

    private static void dfs(int[] arr,int start) {

        if (ret.size() == 4){
            set.add(new ArrayList<Integer>(ret));
            return;
        }

        for(int i = start;i<arr.length;i++){
            ret.add(arr[i]);
            dfs(arr,i+1);
            ret.remove(ret.size()-1);
        }







    }







    /*public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int x = in.nextInt();

        while (x!=0){
            x--;

            int X = in.nextInt();
            String S = in.next();
            int Y = in.nextInt();

            long cap = 0;
            if (S.equals("B")){
                cap = X*1;
            }else if(S.equals("KB")){
                cap = X*1024;
            }else if(S.equals("MB")){
                cap = X*1024*1024;
            }

            System.out.println(cap/Y);

        }



    }*/






/*    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);

        int N = scanner.nextInt();
        scanner.nextLine();
        String S = scanner.nextLine();
        int[][] arr = new int[N-1][2];
        for(int i = 0;i<N-1;i++){
            arr[i][0] = scanner.nextInt();
            arr[i][1] = scanner.nextInt();
        }

        List<Set<Integer>> list = new ArrayList<>();
        for(int i= 0;i<N-1-1;i++){
            for(int j = i+1;j<N-1;j++){
                if (arr[i][0] == arr[j][0] || arr[i][0] ==arr[j][1] || arr[i][1]==arr[j][0] || arr[i][1]==arr[j][1]){
                    Set<Integer> tmp = new HashSet<>();
                    tmp.add(arr[i][0]);
                    tmp.add(arr[i][1]);
                    tmp.add(arr[j][0]);
                    tmp.add(arr[j][1]);
                    list.add(tmp);
                }
            }
        }


        char[] ch = S.toCharArray();
        for(Set<Integer> tmp:list){
            List<Integer> tmp1 = new ArrayList<>(tmp);
            if (ch[tmp1.get(0)-1] == ch[tmp1.get(1)-1] && ch[tmp1.get(2)-1] == ch[tmp1.get(1)-1]){
                System.out.println("NO");
                return;
            }
//            System.out.println(tmp1);
        }

        System.out.println("YES");


    }*/



}
